// 这是通过appTool自动生成的rpcx代码，请勿修改
package serverRpc

import (
	"github.com/sirupsen/logrus"
	"github.com/smallnest/rpcx/client"
)

var (
	gClient                client.XClient
	discoverys             []client.ServiceDiscovery
	lg                     = logrus.New().WithField("tag", "rpc")
	ClientInitDoneCallback func(client.XClient)
)

func RpcxClients(discovery client.ServiceDiscovery, failMode client.FailMode, selectMode client.SelectMode, option client.Option) {
	if gClient == nil {
		d, _ := discovery.Clone("server.globalFun")
		discoverys = append(discoverys, d)
		gClient = client.NewXClient("server.globalFun", failMode, selectMode, d, option)
		clientInitDone(gClient)
	}
}
func RpcxClose() {
	if gClient != nil {
		gClient.Close()
		gClient = nil
	}
	for _, d := range discoverys {
		d.Close()
	}
	discoverys = nil
}
func SetLogger(l *logrus.Entry) {
	lg = l
}
func clientInitDone(c client.XClient) {
	if ClientInitDoneCallback != nil {
		ClientInitDoneCallback(c)
	}
}
